package org.example.qst.common;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class Result<T> {

    private Integer code;
    private String message;
    private boolean flag;
    private T data;

    public static <U> Result<U> success(U data){
        Result<U> tResult = new Result<>();
        tResult.setCode(20000);
        tResult.setMessage("success");
        tResult.setFlag(true);
        tResult.setData(data);
        return tResult;
    }

    public static <U> Result<U> failure(String msg){
        Result<U> tResult = new Result<>();
        tResult.setCode(10005);
        tResult.setMessage(msg);
        tResult.setFlag(false);
        return tResult;
    }
}
